#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Date : 2024/7/19
# @Author : shiyou pan

"""
NOTE: 获取Wind EDB数据，需要先安装WindPy库，并使用w.start()启动Wind API
"""

import pandas as pd
from WindPy import w

from macros.utils import TODAY

w.start()


def get_edb_wind(list_code: list[str], date_start: str = '2000-01-01', date_end: str = TODAY) -> pd.DataFrame:
    """
    获取Wind EDB数据

    params
    ------
    list_code: list[str]
        万德宏观指标代码列表
    date_start: str = '2000-01-01'
        开始日期，默认值为2000-01-01，格式：YYYY-MM-DD
    date_end: str = TODAY
        结束日期，默认值为当天日期，格式：YYYY-MM-DD

    return
    ------
    pd.DataFrame
        宏观经济数据集
    """
    edb = w.edb(','.join(list_code), date_start, date_end)
    if edb.ErrorCode == 0:
        data = pd.DataFrame(edb.Data, index=edb.Codes, columns=edb.Times).T
        data.index = data.index.astype(str)
        return data
    else:
        return pd.DataFrame()


if __name__ == '__main__':
    pass
